﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ElingOA6_DSJCJ.Common;
using System.Data;
using Webdiyer.WebControls.Mvc;
using System.Configuration;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using ElingOA6_DSJCJ.Models;

namespace ElingOA6_DSJCJ.Controllers
{
    /// <summary>
    /// 专题专栏
    /// </summary>
    [OutputCache(Duration = 0, VaryByParam = "none")]
    public class ColumnController : Controller
    {
        //
        // GET: /Column/
        private BLL.DocRecObject docRecObjectBLL = new BLL.DocRecObject();
        private BLL.DocAttach docAttachBLL = new BLL.DocAttach();
        private BLL.DocReadLog docReadLogBLL = new BLL.DocReadLog();
        private BLL.DocCls docClsBLL = new BLL.DocCls();
        private BLL.ClsTempl clsTemplBLL = new BLL.ClsTempl();
        private BLL.Common commonBLL = new BLL.Common();
        private BLL.Document documentBLL = new BLL.Document();

        public ActionResult Index()
        {
            return View();
        }
        public ActionResult ZtzlColumn(string clsCd)
        {
            ActionResult actionResult = null;
            Model.DocCls docClsModel = docClsBLL.GetModel(Common.GlobalConstant.ENTITYNO, clsCd);
            if (docClsModel != null)
            {
                  if (docClsModel.FIsUse==0)
                  {
                      Response.Write("<script>alert('当前专题专栏栏目不启用') ;window.close();</script>");
                      Response.Flush();
                      Response.End();
                  }
                if (docClsModel.FClsTemplID.HasValue)
                {
                    Model.ClsTempl clsTemplModel = clsTemplBLL.GetModel(docClsModel.FClsTemplID.Value, Common.GlobalConstant.ENTITYNO);
                    if (clsTemplModel != null)
                    {
                      
                        clsTemplModel.FTemplShowPath = clsTemplModel.FTemplShowPath.Replace("<#Field:FDocClsCd>", clsCd);
                        Response.Write("<script>window.location.href='" + clsTemplModel.FTemplShowPath + "'</script>");
                        Response.Flush();
                        Response.End();
                    }
                }
            }

            return actionResult;
        }
        /// <summary>
        /// 专题专栏列表
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult ZtzlList()
        {
            string preDocClsCd = Common.GenerateUtil.GetConfigValue("doc_ztzl_cls");
            Dictionary<string, string> zlOldDic = new Dictionary<string, string>();
            if (preDocClsCd != "")
            {
                zlOldDic = docClsBLL.GetIdAndLogUrlAll(preDocClsCd, GlobalConstant.ENTITYNO, 0);

            }
            ViewData["zlOldDic"] = zlOldDic;
            return View();
        }
        /// <summary>
        /// 默认的专题专栏模板
        /// </summary>
        /// <param name="clsCd"></param>
        /// <returns></returns>
        public ActionResult DefalutZtzl(string clsCd)
        {
            return View("DefalutZtzl");
        }
        

       
        /// <summary>
        /// 列表页
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <param name="pageIndex"></param>
        /// <param name="docClsCd"></param>
        /// <returns></returns>
        private List<Models.DocumentGridModel> GetDocList(int pageSize, out int total, string docClsCd, int pageIndex = 1)
        {
            bool isLogin = string.IsNullOrEmpty(OperateSession.get(GlobalConstant.PARAM_LOGINID)) ? false : true;
            total = 0;
            List<Models.DocumentGridModel> documentList = new List<Models.DocumentGridModel>();
            string empNo = OperateSession.get(GlobalConstant.PARAM_FEMPLNO);
            string fieldOrder = " FIsTop DESC,FTopSeq ASC,FDisplayDate";
            if (isLogin)
            {
                //已登录
                //栏目: 1、不控制查看权限 或者 2、控制查看权限，公开标题 或者 3、控制查看权限，不公开标题，有权限
                string strWhere = "";
                string fiedls = "*";
                string tableName = "";
                tableName = "dbo.fn_GetIndexDocument_DocClsCd__NoConfig_ByCTE_Login('" + GlobalConstant.ENTITYNO + "','" + empNo + "','" + docClsCd + "')";

                DataSet ds = commonBLL.GetListByPage(tableName, fiedls, pageSize, pageIndex, strWhere, fieldOrder, 1, out total);
                documentList = ViewDataRowToModel.DataTableToListDocuemt(ds.Tables[0]);
            }
            else
            {
                //未登录
                //栏目：1、不控制查看权限 或者 2、控制查看权限，公开标题
                string strWhere = "";
                string fiedls = "*";
                string tableName = "";
                tableName = "dbo.fn_GetIndexDocument_DocClsCd_NoConfig_ByCTE_NotLogin('" + GlobalConstant.ENTITYNO + "','" + docClsCd + "')";

                DataSet ds = commonBLL.GetListByPage(tableName, fiedls, pageSize, pageIndex, strWhere, fieldOrder, 1, out total);
                documentList = ViewDataRowToModel.DataTableToListDocuemt(ds.Tables[0]);
            }
            return documentList;
        }
        /// <summary>
        /// 获取对应类别的模版顶部图片路径
        /// </summary>
        /// <param name="docClsModel"></param>
        /// <returns></returns>
        private string GetTemplTopPicPath(Model.DocCls docClsModel)
        {
            string imgPath = "";
            //获取最上级有模板顶部图片路径的栏目
            if (!string.IsNullOrEmpty(docClsModel.FPreDocClsCd))
            {
                Model.DocCls tmpDocClsModel = new Model.DocCls();
                tmpDocClsModel = docClsBLL.GetModel(docClsModel.FEntityNo, docClsModel.FPreDocClsCd);
                while (tmpDocClsModel != null && !string.IsNullOrEmpty(tmpDocClsModel.FPreDocClsCd) && string.IsNullOrEmpty(tmpDocClsModel.FTemplTopPicPath))
                {
                    tmpDocClsModel = docClsBLL.GetModel(tmpDocClsModel.FEntityNo, tmpDocClsModel.FPreDocClsCd);
                }
                if (tmpDocClsModel != null)
                {
                    imgPath = tmpDocClsModel.FTemplTopPicPath;
                }
            }
            else
            {
                imgPath = docClsModel.FTemplTopPicPath;
            }
            return imgPath;
        }


        /// <summary>
        /// 三思三创（多栏目）
        /// </summary>
        /// <param name="clsCd"></param>
        /// <returns></returns>
        public ActionResult Sssc(string clsCd)
        {
            ActionResult actionResult = null;

            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            ViewData["logUrl"] = "";
            ViewData["docClsCd"] = clsCd;
            ViewData["docClsName"] = docClsModel.FDocClsName;
            if (docClsModel != null)
            {
                int total = 0;
                string entityNo = GlobalConstant.ENTITYNO;


                //banner
                ViewData["logUrl"] = docClsModel.FTemplTopPicPath;

                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
                total = 0;
                BLL.Entity entityBLL = new BLL.Entity();
               


                List<Model.DocCls> subDocClsList = docClsBLL.GetSubDocClsOneList(clsCd, GlobalConstant.ENTITYNO);

                foreach (Model.DocCls subDocClsModel in subDocClsList)
                {
                    string tmpClsNo = subDocClsModel.FDocClsCd;
                    dicDocumentList.Add(tmpClsNo, GetDocList(8, out total, tmpClsNo, 1));
                    dicDocClsNameList.Add(tmpClsNo, subDocClsModel.FDocClsName);
                }

                ViewData["dicDocClsNameList"] = dicDocClsNameList;//栏目名称集合

                //获取权属
               
                ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);
                actionResult = View("Sssc", dicDocumentList);
            }
            return actionResult;
        }
        /// <summary>
        /// 三思三创内容页
        /// </summary>
        /// <param name="clsCd"></param>
        /// <returns></returns>
        public ActionResult Sssc_Detail(decimal docId)
        {
            ActionResult actionResult = null;
             Model.Document documentModel = documentBLL.GetModel(docId);
            ViewData["logUrl"] = "";
            string clsCd=documentModel.FDocClsCd;
              Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
         string preclscd;
            if (!string.IsNullOrEmpty(docClsModel.FPreDocClsCd))
            {
           
            preclscd=docClsModel.FPreDocClsCd;

           } 
            else
            {
              preclscd=docClsModel.FDocClsCd;
            }
            ViewData["logUrl"] = "";
            ViewData["currentClscd"] = docClsModel.FDocClsCd;
            ViewData["docClsCd"] = preclscd;
            ViewData["docClsName"] = docClsModel.FDocClsName;
            if (docClsModel != null)
            {
                int total = 0;
                string entityNo = GlobalConstant.ENTITYNO;


                //banner
                ViewData["logUrl"] = GetTemplTopPicPath(docClsModel);

                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
                total = 0;

                List<Model.DocCls> subDocClsList = docClsBLL.GetSubDocClsOneList(preclscd, GlobalConstant.ENTITYNO);

                foreach (Model.DocCls subDocClsModel in subDocClsList)
                {
                    string tmpClsNo = subDocClsModel.FDocClsCd;
                    dicDocumentList.Add(tmpClsNo, GetDocList(8, out total, tmpClsNo, 1));
                    dicDocClsNameList.Add(tmpClsNo, subDocClsModel.FDocClsName);
                }

                ViewData["dicDocClsNameList"] = dicDocClsNameList;//栏目名称集合

                //获取权属
                BLL.Entity entityBLL = new BLL.Entity();
                ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);
            }

            string viewDocClsCd = preclscd;
            actionResult = DocView(docId, "Sssc_Detail", viewDocClsCd);

            return actionResult;
        }


        public ActionResult DocView(decimal docId, string viewName = "", string viewDocClsCd = "")
        {
            ViewData["docClsCd"] = viewDocClsCd;
            ViewData["logUrl"] = "";//专题专栏top图片地址
            string entityNo = GlobalConstant.ENTITYNO;
            Model.Document documentModel = documentBLL.GetModel(docId);
            if (documentModel != null)
            {

                Model.DocCls docClsModel1 = docClsBLL.GetModel(entityNo, documentModel.FDocClsCd);
                if (docClsModel1 != null)
                {
                    ViewData["docName"] = docClsModel1.FDocClsName;
                }
                ViewData["FDocId"] = documentModel.FDocId;
                ViewData["navi"] = "当前位置：首页 > " + ViewData["docName"].ToString();
                //发布部门名称
                BLL.HRDept hrDeptBLL = new BLL.HRDept();
                documentModel.FDeptName = hrDeptBLL.GetDeptName(entityNo, documentModel.FDeptNo);
                //发布人
                BLL.HREmpl hrEmplBLL = new BLL.HREmpl();
                documentModel.FEmpName = hrEmplBLL.GetEmpName(entityNo, documentModel.FEmplNo);
                //获取信息类别
                string docClsCd = "";
                //11.21修改保留局长批示
                //if (viewDocClsCd != "")//如果是专题专栏
                //{
                //    docClsCd = viewDocClsCd;
                //}
                //else
                //{
                //    docClsCd = documentModel.FDocClsCd;
                //}
                docClsCd = documentModel.FDocClsCd;
                Model.DocCls docClsModel = docClsBLL.GetModel(entityNo, docClsCd);
                if (docClsModel != null)
                {
                    ViewData["logUrl"] = GetTemplTopPicPath(docClsModel);
                    string empNo = OperateSession.get(GlobalConstant.PARAM_FEMPLNO);
                    string deptNo = OperateSession.get(GlobalConstant.PARAM_DEPTNO);
                    bool isLook = true;//是否可查看
                    bool isAddReadLog = false;//是否需要插入信息文档查看记录
                    string url = "";
                    string newofficetype = "1";//默认office文档类型
                   documentModel.FContentTxt = documentModel.FContentTxt.Replace("&nbsp;&nbsp;&nbsp;&nbsp;", "　");//替换成中文的空格
                    //上传图片
                    List<Model.DocAttach> docAttachPicList = docAttachBLL.GetDocAttachListByDocID(docId, "PIC");
                    string strView = "";
                    if (docAttachPicList.Count > 0)
                    {
                        strView += "<div style='text-align: center'>";
                        foreach (Model.DocAttach docAttachModel in docAttachPicList)
                        {
                            strView += "<img alt='' width='600' height='400' src='" + Url.Action("IndexImageWithDocid", "Index", new { pt = docAttachModel.FAttachSvrFileName, docid = docId }) + "' /><br /><br />";
                        }
                        strView += "</div>";
                    }
                    documentModel.FContentTxt = strView + documentModel.FContentTxt;

                    if (documentModel.FIsEnroll == "N" || documentModel.FRecycle == "Y")
                    {
                        isLook = false;
                    }
                    else
                    {

                        //是否控制查看权限
                        if (docClsModel.FIsCtrlLookAuthority == "Y")
                        {
                            if (string.IsNullOrEmpty(empNo) || string.IsNullOrEmpty(deptNo))
                            {
                                //控制到信息 everyone可见的
                                if (docClsModel.FLookAuthorityMode == "D" && documentBLL.IsDocumentAuthorityForEveryone(docId))
                                {
                                    isLook = true;
                                }
                                else
                                {
                                    isLook = false;
                                }
                            }
                            else
                            {
                                //判断是否控制到信息
                                if (docClsModel.FLookAuthorityMode == "D")
                                {
                                    if (documentBLL.IsDocumentAuthorityForEmpl(empNo, docId))
                                    {
                                        //判断是否通知对象
                                        if (docRecObjectBLL.Exists(entityNo, docId, empNo))
                                        {
                                            isAddReadLog = true;
                                        }
                                    }
                                    else
                                    {
                                        isLook = false;
                                    }

                                }
                                else//控制到栏目
                                {
                                    if (documentBLL.IsDocAuthorityForEmpl(empNo, docClsCd, entityNo, docId))
                                    {
                                        //判断是否通知对象
                                        if (docRecObjectBLL.Exists(entityNo, docId, empNo))
                                        {
                                            isAddReadLog = true;
                                        }
                                    }
                                    else
                                    {
                                        isLook = false;
                                    }
                                }
                            }
                        }
                        else
                        {
                            //判断是否通知对象
                            if (docRecObjectBLL.Exists(entityNo, docId, empNo))
                            {
                                isAddReadLog = true;
                            }
                        }
                    }
                    if (!isLook)
                    {
                        Response.Write("<script>alert('你无权限查看该信息');window.close();</script>");
                        Response.Flush();
                        Response.End();
                        return null;
                    }
                    else
                    {
                        if (documentModel.FEditMode == "O")
                        {
                            url = "/" + documentModel.FSvrFileName.Substring(1);
                            string extension = url.Substring(url.LastIndexOf('.') + 1).ToUpper();
                            switch (extension)
                            {
                                case "DOC":
                                    newofficetype = "1";
                                    break;
                                case "DOCX":
                                    newofficetype = "1";
                                    break;
                                case "XLS":
                                    newofficetype = "2";
                                    break;
                                case "XLSX":
                                    newofficetype = "2";
                                    break;
                                case "PPT":
                                    newofficetype = "3";
                                    break;
                                case "PPTX":
                                    newofficetype = "3";
                                    break;
                                default:
                                    newofficetype = "1";
                                    break;
                            }

                        }

                        //获取权属
                        BLL.Entity entityBLL = new BLL.Entity();
                        ViewData["CopyRight"] = entityBLL.GetCopyRight(GlobalConstant.ENTITYNO);

                        //附件
                        List<Model.DocAttach> docAttachList = docAttachBLL.GetDocAttachListByDocID(docId, "DOC");// attachBll.GetList(GlobalConstant.CONSTRING_ENTITYNO, docID, "DOC");

                        ViewData["docAttach"] = docAttachList;
                        try
                        {
                            documentBLL.UpdateReadCntByDocId(docId); //更新查看次数
                            documentModel.FReadCnt++;
                        }
                        catch
                        {

                        }

                        ViewData["url"] = url;
                        ViewData["newofficetype"] = newofficetype;

                        if (null == OperateSession.get(GlobalConstant.PARAM_PRODUCTCAPTION) || null == OperateSession.get(GlobalConstant.PARAM_PRODUCTKEY))
                        {
                            //从数据库获取Ntko Office控件序列号
                            BLL.Entity entityBll = new BLL.Entity();
                            Model.Entity entityModel = entityBll.GetModel(GlobalConstant.ENTITYNO);
                            if (entityModel != null)
                            {
                                OperateSession.add(GlobalConstant.PARAM_PRODUCTKEY, entityModel.FNTKOKey);
                                OperateSession.add(GlobalConstant.PARAM_PRODUCTCAPTION, entityModel.FNTKOCaption);
                            }
                        }


                        ViewData["ProductCaption"] = OperateSession.get(GlobalConstant.PARAM_PRODUCTCAPTION);
                        ViewData["ProductKey"] = OperateSession.get(GlobalConstant.PARAM_PRODUCTKEY);

                        if (string.IsNullOrEmpty(empNo) || string.IsNullOrEmpty(deptNo))
                        {
                            //未登录

                        }
                        else
                        {
                            //已登录
                            //获取部门信息
                            string emplNo = OperateSession.get(GlobalConstant.PARAM_FEMPLNO);
                            string deptName = "";
                            string empName = "";
                            if (emplNo != "" && entityNo != "")
                            {
                                DataSet ds = hrEmplBLL.GetEmplFromViewByEmplNo(emplNo, entityNo);
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    DataTable dt = ds.Tables[0];
                                    for (int i = 0; i < dt.Rows.Count; i++)
                                    {
                                        if (dt.Rows[i]["FIsMainPosition"].ToString() == "Y")
                                        {
                                            ViewData["EmpName"] = dt.Rows[i]["FEmpName"].ToString();
                                            ViewData["DeptName"] = dt.Rows[i]["FDeptName"].ToString();
                                            deptName = ViewData["DeptName"].ToString();
                                            empName = ViewData["EmpName"].ToString();
                                            OperateSession.add(GlobalConstant.PARAM_DEPTNO, dt.Rows[i]["FDeptNo"].ToString());
                                            break;
                                        }

                                    }
                                }
                            }
                            if (isAddReadLog)
                            {
                                //判断是否已经阅读
                                if (!docReadLogBLL.Exists(entityNo, docId, empNo))
                                {
                                    //插入信息文档查看记录
                                    Model.DocReadLog docReadLogModel = new Model.DocReadLog();
                                    docReadLogModel.FEntityNo = entityNo;
                                    docReadLogModel.FDocId = docId;
                                    docReadLogModel.FDeptNo = OperateSession.get(GlobalConstant.PARAM_DEPTNO);
                                    docReadLogModel.FDeptName = deptName;
                                    docReadLogModel.FEmplNo = OperateSession.get(GlobalConstant.PARAM_FEMPLNO);
                                    docReadLogModel.FEmpName = empName;
                                    docReadLogModel.FReadTime = DateTime.Now;
                                    docReadLogModel.FIPAddr = Request.UserHostAddress;
                                    try
                                    {
                                        docReadLogBLL.Add(docReadLogModel);
                                    }
                                    catch
                                    {

                                    }
                                }
                            }
                        }
                        ViewData["isVote"] = docClsModel.FIsVote;


                        //获取批示权限
                        if (docClsModel.FIsExamine == "Y")
                        {
                            BLL.PrvUser prvUserBll = new BLL.PrvUser();
                            Model.PrvUser prvUserModel = prvUserBll.GetModel(OperateSession.get(GlobalConstant.PARAM_LOGINID), GlobalConstant.ENTITYNO);
                            string fisIns = "";
                            if (prvUserModel != null)
                            {
                                fisIns = prvUserModel.FIsInstruct;
                            }
                            ViewData["FIsInstruct"] = fisIns == null ? "" : fisIns;
                            ViewData["FEmplNo"] = OperateSession.get(GlobalConstant.PARAM_FEMPLNO);
                            if (ViewData["FEmplNo"] == null)
                            {
                                ViewData["FEmplNo"] = "";
                            }

                            //获取领导批示列表
                            BLL.LeadInstruct leadInstructBLL = new BLL.LeadInstruct();
                            string strWhere = "FDocId=" + documentModel.FDocId + " and a.FEntityNo='" + GlobalConstant.ENTITYNO + "'";
                            DataSet dslt = leadInstructBLL.GetList(strWhere);
                            ViewData["leadInstruct"] = dslt;
                            ViewData["FDocId"] = documentModel.FDocId;
                        }

                        ViewData["FIsExamine"] = docClsModel.FIsExamine != "Y" ? "N" : "Y";

                        //处理图片
                        string pattern1 = "width\\s?=\\s?\"(\\d+)\"\\s+height\\s?=\\s?\"(\\d+)";
                        string pattern2 = "width\\s?:\\s?(\\d+)px;\\s+height\\s?:\\s?(\\d+)px";
                        int matchType = 0;
                        //利用正则替换内容模块
                        MatchCollection tdMatchs = Regex.Matches(documentModel.FContentTxt,
                        @"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>",
                        RegexOptions.IgnoreCase | RegexOptions.Multiline);

                        for (int i = tdMatchs.Count - 1; i >= 0; i--)
                        {
                            string oldimgUrl = tdMatchs[i].Value;
                            MatchCollection tdMatchsTmp = Regex.Matches(oldimgUrl,
                        pattern1, RegexOptions.IgnoreCase | RegexOptions.Multiline);
                            if (tdMatchsTmp.Count == 0)
                            {
                                tdMatchsTmp = Regex.Matches(oldimgUrl,
                       pattern2, RegexOptions.IgnoreCase | RegexOptions.Multiline);
                                matchType = 2;
                            }
                            else
                            {
                                matchType = 1;
                            }
                            if (tdMatchsTmp.Count > 0)
                            {

                                string imgSizeValue = tdMatchsTmp[0].Value;
                                string width = tdMatchsTmp[0].Groups[1].Value; //宽    
                                string height = tdMatchsTmp[0].Groups[2].Value; //高 
                                int _width = 0;
                                int _height = 0;
                                int newWidth = 0;
                                int newHeight = 0;
                                if (int.TryParse(width, out _width) && int.TryParse(height, out _height))
                                {
                                    if (_width > GlobalConstant.IMG_SHOW_MAXWIDTH)
                                    {
                                        newWidth = GlobalConstant.IMG_SHOW_MAXWIDTH;
                                        newHeight = (_height * GlobalConstant.IMG_SHOW_MAXWIDTH) / _width;
                                        string newImgUrl = "";
                                        if (matchType == 1)
                                        {
                                            newImgUrl = oldimgUrl.Replace(imgSizeValue, "width='" + newWidth + "' height='" + newHeight + "'");
                                        }
                                        else
                                        {
                                            newImgUrl = oldimgUrl.Replace(imgSizeValue, "width:" + newWidth + "px; height:" + newHeight + "px");
                                        }
                                        documentModel.FContentTxt = documentModel.FContentTxt.Replace(oldimgUrl, newImgUrl);
                                    }
                                }

                            }
                        }


                        //获取此文档被引用的栏目
                        BLL.DocRefImp docRefImp = new BLL.DocRefImp();
                        List<Model.DocRefImp> docRefImpList = docRefImp.GetListByDocId(GlobalConstant.ENTITYNO, docId);
                        string docRefImpClsName = "";
                        if (docRefImpList.Count > 0)
                        {
                            List<CommonValueModel> commValueList = new List<CommonValueModel>();
                            foreach (Model.DocRefImp docRefImpModel in docRefImpList)
                            {
                                commValueList.Add(new CommonValueModel { Text = docRefImpModel.FDocClsName, Value = docRefImpModel.FDocClsCd });
                                docRefImpClsName += docRefImpModel.FDocClsName + ",";
                            }

                            if (docRefImpClsName != "")
                            {
                                docRefImpClsName = "此信息已被下列栏目引用：" + docRefImpClsName.Trim(',');
                            }

                            ViewData["docRefImpClsName"] = docRefImpClsName;
                            ViewData["docRefImpClsJson"] = JsonConvert.SerializeObject(commValueList);
                        }
                        else
                        {
                            ViewData["docRefImpClsName"] = "";
                            ViewData["docRefImpClsJson"] = "";
                        }




                        if (viewName == "")
                        {
                            return View("DocView", documentModel);
                        }
                        else
                        {
                            return View(viewName, documentModel);
                        }
                    }

                }
                else
                {
                    Response.Write("<script>alert('对应信息类别不存在');window.close();</script>");
                    Response.Flush();
                    Response.End();
                    return null;
                }

            }
            else
            {
                Response.Write("<script>alert('信息不存在');window.close();</script>");
                Response.Flush();
                Response.End();
                return null;
            }
        }
        /// <summary>
        /// 三思三创列表页
        /// </summary>
        /// <param name="clsCd"></param>
        /// <returns></returns>
        public ActionResult Sssc_List(string clsCd, int id = 1)
        {
            int total;
            string entityNo = GlobalConstant.ENTITYNO;
            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            string preclscd;
            if (!string.IsNullOrEmpty(docClsModel.FPreDocClsCd))
            {

                preclscd = docClsModel.FPreDocClsCd;

            }
            else
            {
                preclscd = docClsModel.FDocClsCd;
            }
            ViewData["logUrl"] = "";
            ViewData["docClsCd"] = preclscd;
            ViewData["docClsName"] = docClsModel.FDocClsName;
            if (docClsModel != null)
            {
                total = 0;
                entityNo = GlobalConstant.ENTITYNO;


                //banner
                ViewData["logUrl"] = GetTemplTopPicPath(docClsModel);

                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
                total = 0;

                List<Model.DocCls> subDocClsList = docClsBLL.GetSubDocClsOneList(preclscd, GlobalConstant.ENTITYNO);
                string docClsHtml = "<ul>";
                foreach (Model.DocCls subDocClsModel in subDocClsList)
                {
                    docClsHtml += "<li><h2><a href='/Column/Sssc_List?clsCd=" + subDocClsModel.FDocClsCd.ToString();
                    docClsHtml += "' >" + subDocClsModel.FDocClsName.ToString() + "</a></h2></li>";
                    string tmpClsNo = subDocClsModel.FDocClsCd;
                    dicDocumentList.Add(tmpClsNo, GetDocList(8, out total, tmpClsNo, 1));
                    dicDocClsNameList.Add(tmpClsNo, subDocClsModel.FDocClsName);
                }
                docClsHtml += "</ul>";
                ViewData["dicDocClsNameList"] = dicDocClsNameList;//栏目名称集合
                BLL.Entity entityBLL = new BLL.Entity();
                ViewData["docClsHtml"] = docClsHtml;
                ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);
                ViewData["focusCd"] = docClsModel.FDocClsCd;
            }
            entityNo = GlobalConstant.ENTITYNO;
            int pageSize = 20;
            total = 0;
            List<Models.DocumentGridModel> docGridList = GetDocList(pageSize, out total, clsCd, id);
            PagedList<Models.DocumentGridModel> documentList = new PagedList<Models.DocumentGridModel>(docGridList, id, pageSize, total);

            docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);


            return View(documentList);

            //string entityNo = GlobalConstant.ENTITYNO;
            //int pageSize = 20;
            //int total = 0;
            //List<Models.DocumentGridModel> docGridList = GetDocList(pageSize, out total, clsCd, id);
            //PagedList<Models.DocumentGridModel> documentList = new PagedList<Models.DocumentGridModel>(docGridList, id, pageSize, total);
            //ViewData["logUrl"] = "";
            //Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            //if (docClsModel != null)
            //{
            //    ViewData["docClsName"] = docClsModel.FDocClsName;
            //    ViewData["logUrl"] = GetTemplTopPicPath(docClsModel);
            //    ViewData["focusCd"] = docClsModel.FDocClsCd;

            //    Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
            //    DataSet ds = docClsBLL.GetSubDocCls(clsCd, entityNo);
            //    if (ds.Tables.Count > 0)
            //    {
            //        foreach (DataRow dr in ds.Tables[0].Rows)
            //        {
            //            dicDocClsNameList.Add(dr["FDocClsCd"].ToString(), dr["FDocClsName"].ToString());
            //        }
            //    }
            //    ViewData["dicDocClsNameList"] = dicDocClsNameList;
            //}

            ////获取权属
            //BLL.Entity entityBLL = new BLL.Entity();
            //ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);

            //return View(documentList);
        }





        /// <summary>
        /// 十七大（单栏目）
        /// </summary>
        /// <param name="clsCd"></param>
        /// <returns></returns>
        public ActionResult shiqida(string clsCd)
        {
            ActionResult actionResult = null;

            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            ViewData["logUrl"] = "";
            ViewData["docClsCd"] = clsCd;
            if (docClsModel != null)
            {
                ViewData["docClsName"] = docClsModel.FDocClsName;
                ViewData["logUrl"] = docClsModel.FTemplTopPicPath;
                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                int total = 0;
                List<Models.DocumentGridModel> documentList = GetDocList(10, out total, clsCd, 1);
                dicDocumentList.Add(clsCd, documentList);

                //获取权属
                BLL.Entity entityBLL = new BLL.Entity();
                ViewData["CopyRight"] = entityBLL.GetCopyRight(GlobalConstant.ENTITYNO);
                actionResult = View("shiqida", dicDocumentList);
            }
            return actionResult;
        }
        /// <summary>
        /// 十七大内容页
        /// </summary>
        /// <param name="clsCd"></param>
        /// <returns></returns>
        public ActionResult shiqida_Detail(decimal docId)
        {
            ActionResult actionResult = null;
            ViewData["logUrl"] = "";
            Model.Document documentModel = documentBLL.GetModel(docId);
            ViewData["logUrl"] = "";
            string clsCd = documentModel.FDocClsCd;
            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            string preclscd;
            if (!string.IsNullOrEmpty(docClsModel.FPreDocClsCd))
            {

                preclscd = docClsModel.FPreDocClsCd;

            }
            else
            {
                preclscd = docClsModel.FDocClsCd;
            }
            ViewData["logUrl"] = "";
            ViewData["docClsCd"] = clsCd;
            ViewData["docClsName"] = docClsModel.FDocClsName;
            if (docClsModel != null)
            {
                int total = 0;
                string entityNo = GlobalConstant.ENTITYNO;


                //banner
                ViewData["logUrl"] = docClsModel.FTemplTopPicPath;

                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
                total = 0;

                List<Model.DocCls> subDocClsList = docClsBLL.GetSubDocClsOneList(preclscd, GlobalConstant.ENTITYNO);

                foreach (Model.DocCls subDocClsModel in subDocClsList)
                {
                    string tmpClsNo = subDocClsModel.FDocClsCd;
                    dicDocumentList.Add(tmpClsNo, GetDocList(8, out total, tmpClsNo, 1));
                    dicDocClsNameList.Add(tmpClsNo, subDocClsModel.FDocClsName);
                }

                ViewData["dicDocClsNameList"] = dicDocClsNameList;//栏目名称集合

                //获取权属
                BLL.Entity entityBLL = new BLL.Entity();
                ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);
            }
            


            IndexController indexCl = new IndexController();
            string viewDocClsCd = "8001";
            actionResult = DocView(docId, "shiqida_Detail", viewDocClsCd);

            return actionResult;
        }
        /// <summary>
        /// 十七大列表页
        /// </summary>
        /// <param name="clsCd"></param>
        /// <returns></returns>
        public ActionResult shiqida_List(string clsCd, int id = 1)
        {
            string entityNo = GlobalConstant.ENTITYNO;
            int pageSize = 20;
            int total = 0;
            List<Models.DocumentGridModel> docGridList = GetDocList(pageSize, out total, clsCd, id);
            PagedList<Models.DocumentGridModel> documentList = new PagedList<Models.DocumentGridModel>(docGridList, id, pageSize, total);
            ViewData["logUrl"] = "";
            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            if (docClsModel != null)
            {
                ViewData["docClsCd"] = docClsModel.FDocClsCd;
                ViewData["docClsName"] = docClsModel.FDocClsName;
                ViewData["logUrl"] = docClsModel.FTemplTopPicPath;
            }

            //获取权属
            BLL.Entity entityBLL = new BLL.Entity();
            ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);

            return View(documentList);
        }


        /// <summary>
        /// 十八大（多栏目）
        /// </summary>
        /// <param name="clsCd"></param>
        /// <returns></returns>
        public ActionResult Shibada(string clsCd)
        {
            ActionResult actionResult = null;

            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            ViewData["logUrl"] = "";
            ViewData["docClsCd"] = clsCd;
            ViewData["docClsName"] = docClsModel.FDocClsName;
            if (docClsModel != null)
            {
                int total = 0;
                string entityNo = GlobalConstant.ENTITYNO;


                //banner
                ViewData["logUrl"] = docClsModel.FTemplTopPicPath;

                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
                total = 0;

                List<Model.DocCls> subDocClsList = docClsBLL.GetSubDocClsOneList(clsCd, GlobalConstant.ENTITYNO);

                foreach (Model.DocCls subDocClsModel in subDocClsList)
                {
                    string tmpClsNo = subDocClsModel.FDocClsCd;
                    dicDocumentList.Add(tmpClsNo, GetDocList(8, out total, tmpClsNo, 1));
                    dicDocClsNameList.Add(tmpClsNo, subDocClsModel.FDocClsName);
                }

                ViewData["dicDocClsNameList"] = dicDocClsNameList;//栏目名称集合

                //获取权属
                BLL.Entity entityBLL = new BLL.Entity();
                ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);
                actionResult = View("Shibada", dicDocumentList);
            }
            return actionResult;
        }
        public ActionResult lzzc(string clsCd)
        {
            ActionResult actionResult = null;

            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            ViewData["logUrl"] = "";
            ViewData["docClsCd"] = clsCd;
            ViewData["docClsName"] = docClsModel.FDocClsName;
            if (docClsModel != null)
            {
                int total = 0;
                string entityNo = GlobalConstant.ENTITYNO;


                //banner
                ViewData["logUrl"] = docClsModel.FTemplTopPicPath;

                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
                total = 0;

                List<Model.DocCls> subDocClsList = docClsBLL.GetSubDocClsOneList(clsCd, GlobalConstant.ENTITYNO);

                foreach (Model.DocCls subDocClsModel in subDocClsList)
                {
                    string tmpClsNo = subDocClsModel.FDocClsCd;
                    dicDocumentList.Add(tmpClsNo, GetDocList(8, out total, tmpClsNo, 1));
                    dicDocClsNameList.Add(tmpClsNo, subDocClsModel.FDocClsName);
                }

                ViewData["dicDocClsNameList"] = dicDocClsNameList;//栏目名称集合

                //获取权属
                BLL.Entity entityBLL = new BLL.Entity();
                ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);
                actionResult = View("lzzc", dicDocumentList);
            }
            return actionResult;
        }
        /// <summary>
        /// 十八大内容页
        /// </summary>
        /// <param name="clsCd"></param>
        /// <returns></returns>
        public ActionResult Shibada_Detail(decimal docId)
        {
            ActionResult actionResult = null;
            ViewData["logUrl"] = "";
            Model.Document documentModel = documentBLL.GetModel(docId);
            ViewData["logUrl"] = "";
            string clsCd = documentModel.FDocClsCd;
            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            string preclscd;
            if (!string.IsNullOrEmpty(docClsModel.FPreDocClsCd))
            {

                preclscd = docClsModel.FPreDocClsCd;

            }
            else
            {
                preclscd = docClsModel.FDocClsCd;
            }

            ViewData["logUrl"] = "";
            ViewData["currentClscd"] = docClsModel.FDocClsCd;
            ViewData["docClsCd"] = preclscd;
            ViewData["docClsName"] = docClsModel.FDocClsName;
            if (docClsModel != null)
            {
                int total = 0;
                string entityNo = GlobalConstant.ENTITYNO;


                //banner
                ViewData["logUrl"] = GetTemplTopPicPath(docClsModel);

                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
                total = 0;

                List<Model.DocCls> subDocClsList = docClsBLL.GetSubDocClsOneList(preclscd, GlobalConstant.ENTITYNO);

                foreach (Model.DocCls subDocClsModel in subDocClsList)
                {
                    string tmpClsNo = subDocClsModel.FDocClsCd;
                    dicDocumentList.Add(tmpClsNo, GetDocList(8, out total, tmpClsNo, 1));
                    dicDocClsNameList.Add(tmpClsNo, subDocClsModel.FDocClsName);
                }

                ViewData["dicDocClsNameList"] = dicDocClsNameList;//栏目名称集合

                //获取权属
                BLL.Entity entityBLL = new BLL.Entity();
                ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);
            }



            IndexController indexCl = new IndexController();
            string viewDocClsCd = preclscd;
            actionResult = DocView(docId, "shibada_Detail", viewDocClsCd);

            return actionResult;
           
        }
        public ActionResult lzzc_Detail(decimal docId)
        {
            ActionResult actionResult = null;
            ViewData["logUrl"] = "";
            Model.Document documentModel = documentBLL.GetModel(docId);
            ViewData["logUrl"] = "";
            string clsCd = documentModel.FDocClsCd;
            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            string preclscd;
            if (!string.IsNullOrEmpty(docClsModel.FPreDocClsCd))
            {

                preclscd = docClsModel.FPreDocClsCd;

            }
            else
            {
                preclscd = docClsModel.FDocClsCd;
            }
            ViewData["logUrl"] = "";
            ViewData["docClsCd"] = preclscd;
            ViewData["currentClscd"]=docClsModel.FDocClsCd;
            ViewData["docClsName"] = docClsModel.FDocClsName;
            if (docClsModel != null)
            {
                int total = 0;
                string entityNo = GlobalConstant.ENTITYNO;


                //banner
                ViewData["logUrl"] = GetTemplTopPicPath(docClsModel);

                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
                total = 0;

                List<Model.DocCls> subDocClsList = docClsBLL.GetSubDocClsOneList(preclscd, GlobalConstant.ENTITYNO);

                foreach (Model.DocCls subDocClsModel in subDocClsList)
                {
                    string tmpClsNo = subDocClsModel.FDocClsCd;
                    dicDocumentList.Add(tmpClsNo, GetDocList(8, out total, tmpClsNo, 1));
                    dicDocClsNameList.Add(tmpClsNo, subDocClsModel.FDocClsName);
                }

                ViewData["dicDocClsNameList"] = dicDocClsNameList;//栏目名称集合

                //获取权属
                BLL.Entity entityBLL = new BLL.Entity();
                ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);
            }



            IndexController indexCl = new IndexController();
            string viewDocClsCd = preclscd;
            actionResult = DocView(docId, "lzzc_Detail", viewDocClsCd);

            return actionResult;

        }
        /// <summary>
        /// 十八大列表页
        /// </summary>
        /// <param name="clsCd"></param>
        /// <returns></returns>
        public ActionResult Shibada_List(string clsCd, int id = 1)
        {
            int total;
            string entityNo = GlobalConstant.ENTITYNO;
             Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            string preclscd;
            if (!string.IsNullOrEmpty(docClsModel.FPreDocClsCd))
            {

                preclscd = docClsModel.FPreDocClsCd;

            }
            else
            {
                preclscd = docClsModel.FDocClsCd;
            }
            ViewData["logUrl"] = "";
            ViewData["docClsCd"] = preclscd;
            ViewData["docClsName"] = docClsModel.FDocClsName;
            if (docClsModel != null)
            {
                 total = 0;
                 entityNo = GlobalConstant.ENTITYNO;


                //banner
                 ViewData["logUrl"] = GetTemplTopPicPath(docClsModel);

                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
                total = 0;

                List<Model.DocCls> subDocClsList = docClsBLL.GetSubDocClsOneList(preclscd, GlobalConstant.ENTITYNO);
              string  docClsHtml = "<ul>";
                foreach (Model.DocCls subDocClsModel in subDocClsList)
                {
                    docClsHtml += "<li><h2><a href='/Column/Shibada_List?clsCd=" + subDocClsModel.FDocClsCd.ToString();
                    docClsHtml += "' >" + subDocClsModel.FDocClsName.ToString() + "</a></h2></li>";
                    string tmpClsNo = subDocClsModel.FDocClsCd;
                    dicDocumentList.Add(tmpClsNo, GetDocList(8, out total, tmpClsNo, 1));
                    dicDocClsNameList.Add(tmpClsNo, subDocClsModel.FDocClsName);
                }
                docClsHtml += "</ul>";
                ViewData["dicDocClsNameList"] = dicDocClsNameList;//栏目名称集合
                BLL.Entity entityBLL = new BLL.Entity();
                ViewData["docClsHtml"] = docClsHtml;
                ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);
                ViewData["focusCd"] = docClsModel.FDocClsCd;
            } 
             entityNo = GlobalConstant.ENTITYNO;
            int pageSize = 20;
            total = 0;
            List<Models.DocumentGridModel> docGridList = GetDocList(pageSize, out total, clsCd, id);
            PagedList<Models.DocumentGridModel> documentList = new PagedList<Models.DocumentGridModel>(docGridList, id, pageSize, total);
           
          docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);


          return View(documentList);

                //Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
                //DataSet ds = docClsBLL.GetSubDocCls(clsCd, entityNo);
                //if (ds.Tables.Count > 0)
                //{
                //    foreach (DataRow dr in ds.Tables[0].Rows)
                //    {
                //        dicDocClsNameList.Add(dr["FDocClsCd"].ToString(), dr["FDocClsName"].ToString());
                //    }
                //}
                //ViewData["dicDocClsNameList"] = dicDocClsNameList;
            

            //获取权属
           
         

           
        }

        public ActionResult lzzc_List(string clsCd, int id = 1)
        {
            int total;
            string entityNo = GlobalConstant.ENTITYNO;
            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            string preclscd;
            if (!string.IsNullOrEmpty(docClsModel.FPreDocClsCd))
            {

                preclscd = docClsModel.FPreDocClsCd;

            }
            else
            {
                preclscd = docClsModel.FDocClsCd;
            }
            ViewData["logUrl"] = "";
            ViewData["docClsCd"] = preclscd;
            ViewData["docClsName"] = docClsModel.FDocClsName;
            if (docClsModel != null)
            {
                total = 0;
                entityNo = GlobalConstant.ENTITYNO;


                //banner
                ViewData["logUrl"] = GetTemplTopPicPath(docClsModel);

                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
                total = 0;

                List<Model.DocCls> subDocClsList = docClsBLL.GetSubDocClsOneList(preclscd, GlobalConstant.ENTITYNO);
                string docClsHtml = "<ul>";
                foreach (Model.DocCls subDocClsModel in subDocClsList)
                {
                    docClsHtml += "<li><h2><a href='/Column/lzzc_List?clsCd=" + subDocClsModel.FDocClsCd.ToString();
                    docClsHtml += "' >" + subDocClsModel.FDocClsName.ToString() + "</a></h2></li>";
                    string tmpClsNo = subDocClsModel.FDocClsCd;
                    dicDocumentList.Add(tmpClsNo, GetDocList(8, out total, tmpClsNo, 1));
                    dicDocClsNameList.Add(tmpClsNo, subDocClsModel.FDocClsName);
                }
                docClsHtml += "</ul>";
                ViewData["dicDocClsNameList"] = dicDocClsNameList;//栏目名称集合
                BLL.Entity entityBLL = new BLL.Entity();
                ViewData["docClsHtml"] = docClsHtml;
                ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);
                ViewData["focusCd"] = docClsModel.FDocClsCd;
            }
            entityNo = GlobalConstant.ENTITYNO;
            int pageSize = 20;
            total = 0;
            List<Models.DocumentGridModel> docGridList = GetDocList(pageSize, out total, clsCd, id);
            PagedList<Models.DocumentGridModel> documentList = new PagedList<Models.DocumentGridModel>(docGridList, id, pageSize, total);

            docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);


            return View(documentList);

            //Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
            //DataSet ds = docClsBLL.GetSubDocCls(clsCd, entityNo);
            //if (ds.Tables.Count > 0)
            //{
            //    foreach (DataRow dr in ds.Tables[0].Rows)
            //    {
            //        dicDocClsNameList.Add(dr["FDocClsCd"].ToString(), dr["FDocClsName"].ToString());
            //    }
            //}
            //ViewData["dicDocClsNameList"] = dicDocClsNameList;


            //获取权属




        }


        /// <summary>
        /// 群众路线（多栏目）
        /// </summary>
        /// <param name="clsCd"></param>
        /// <returns></returns>
        public ActionResult Qzlx(string clsCd)
        {
            ActionResult actionResult = null;

            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            ViewData["logUrl"] = "";
            ViewData["docClsCd"] = clsCd;
            ViewData["docClsName"] = docClsModel.FDocClsName;
            if (docClsModel != null)
            {
                int total = 0;
                string entityNo = GlobalConstant.ENTITYNO;


                //banner
                ViewData["logUrl"] = docClsModel.FTemplTopPicPath;

                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
                total = 0;

                List<Model.DocCls> subDocClsList = docClsBLL.GetSubDocClsOneList(clsCd, GlobalConstant.ENTITYNO);

                foreach (Model.DocCls subDocClsModel in subDocClsList)
                {
                    string tmpClsNo = subDocClsModel.FDocClsCd;
                    dicDocumentList.Add(tmpClsNo, GetDocList(8, out total, tmpClsNo, 1));
                    dicDocClsNameList.Add(tmpClsNo, subDocClsModel.FDocClsName);
                }

                ViewData["dicDocClsNameList"] = dicDocClsNameList;//栏目名称集合

                //获取权属
                BLL.Entity entityBLL = new BLL.Entity();
                ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);
                actionResult = View("Qzlx", dicDocumentList);
            }
            return actionResult;
        }
        /// <summary>
        /// 十八大内容页
        /// </summary>
        /// <param name="clsCd"></param>
        /// <returns></returns>
        public ActionResult Qzlx_Detail(decimal docId)
        {
            ActionResult actionResult = null;
            ViewData["logUrl"] = "";



            IndexController indexCl = new IndexController();
            string viewDocClsCd = "8003";
            actionResult = indexCl.DocView(docId, "Qzlx_Detail",viewDocClsCd);

            return actionResult;
        }
        /// <summary>
        /// 十八大列表页
        /// </summary>
        /// <param name="clsCd"></param>
        /// <returns></returns>
        public ActionResult Qzlx_List(string clsCd, int id = 1)
        {
            string entityNo = GlobalConstant.ENTITYNO;
            int pageSize = 20;
            int total = 0;
            List<Models.DocumentGridModel> docGridList = GetDocList(pageSize, out total, clsCd, id);
            PagedList<Models.DocumentGridModel> documentList = new PagedList<Models.DocumentGridModel>(docGridList, id, pageSize, total);
            ViewData["logUrl"] = "";
            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            if (docClsModel != null)
            {
                ViewData["docClsName"] = docClsModel.FDocClsName;
                ViewData["logUrl"] = GetTemplTopPicPath(docClsModel);
                ViewData["focusCd"] = docClsModel.FDocClsCd;

                Dictionary<string, string> dicDocClsNameList = new Dictionary<string, string>();
                DataSet ds = docClsBLL.GetSubDocCls(clsCd, entityNo);
                if (ds.Tables.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        dicDocClsNameList.Add(dr["FDocClsCd"].ToString(), dr["FDocClsName"].ToString());
                    }
                }
                ViewData["dicDocClsNameList"] = dicDocClsNameList;
            }

            //获取权属
            BLL.Entity entityBLL = new BLL.Entity();
            ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo);

            return View(documentList);
        }


        #region 廉政之窗
        /// <summary>
        /// 廉政之窗首页
        /// </summary>
        /// <param name="clsCd">栏目编号</param>
        /// <returns>页面</returns>
        public ActionResult LzzcIndex(string clsCd) 
        {
            ActionResult actionResult = null;
            ViewData["docClsCd"] = clsCd;
            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            if (docClsModel != null)
            {
                string entityNo = GlobalConstant.ENTITYNO;
                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                List<Model.DocCls> subDocClsList = docClsBLL.GetSubDocClsOneList(clsCd, GlobalConstant.ENTITYNO);
                int total = 0;
                dicDocumentList.Add("800601", GetDocList(6, out total, "800601", 1));//法规制度
                total = 0;
                dicDocumentList.Add("800602", GetDocList(6, out total, "800602", 1));//惩防体系
                total = 0;
                dicDocumentList.Add("800603", GetDocList(4, out total, "800603", 1));//史海沉钩
                total = 0;
                dicDocumentList.Add("800604", GetDocList(4, out total, "800604", 1));//廉政学院

                total = 0;
                dicDocumentList.Add("80060402", GetDocList(6, out total, "80060402", 1));//学术体会

                total = 0;
                dicDocumentList.Add("800605", GetDocList(4, out total, "800605", 1));//清风寄语
                List<Model.SysPhrase> sysPhraseList = GetSysPhraseList();

                total = 0;
                dicDocumentList.Add("800606", GetDocList(4, out total, "800606", 1));//活动掠影
                total = 0;
                dicDocumentList.Add("800607", GetDocList(9, out total, "800607", 1));//工作动态              
                total = 0;
                dicDocumentList.Add("800608", GetDocList(6, out total, "800608", 1));//反腐在线            
                total = 0;
                dicDocumentList.Add("800609", GetDocList(4, out total, "800609", 1));//作风效能

                ViewData["subDocClsList"] = subDocClsList;

                ViewData["sysPhraseList"] = sysPhraseList;

                actionResult = View("LzzcIndex", dicDocumentList);
            }
            return actionResult;
        }
        /// <summary>
        /// 清风寄语集合
        /// </summary>
        /// <returns></returns>
        private List<Model.SysPhrase> GetSysPhraseList() 
        {
            BLL.SysPhrase sysPhraseBLL = new BLL.SysPhrase();
            List<Model.SysPhrase> sysPhraseList = new List<Model.SysPhrase>();
            string phraseNo = ConfigurationManager.AppSettings["PhraseNo"];
            sysPhraseList = sysPhraseBLL.GetModelList(" FPhraseNo='" + phraseNo + "' order by newID()");

            return sysPhraseList;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public ActionResult Lzzc_DocmentIndex(string clsCd, string indexClsCd = "", string prop = "") 
        {
            ActionResult actionResult = null;

            Model.DocCls docClsModelAll = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            if (docClsModelAll != null)
            {
                ViewData["docClsName"] = docClsModelAll.FDocClsName;
            }

            ViewData["prop"] = prop;
            string entityNo = GlobalConstant.ENTITYNO;
            string docClsCd = docClsBLL.GetDocClsCdS(clsCd, GlobalConstant.ENTITYNO);
            string[] docClsCdArr = docClsCd.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
            string preDocClsCd = docClsCdArr[1].ToString();
            ViewData["docClsCd"] = preDocClsCd;
            if (indexClsCd == "")
            {
                ViewData["clsCd"] = docClsCdArr[2].ToString();
            }
            else 
            {
                ViewData["clsCd"] = indexClsCd;
            }

            string docClsHtml = "";
            DataTable docClsDT = docClsBLL.GetLZZCDocCls(entityNo, clsCd);
            var tmpDocCls = docClsDT.Select("ClsLevel=0").ToList();
            if (docClsDT.Rows.Count == 0)
            {
                Response.Write("<script>alert('该信息类别配置无对应栏目信息');</script>");
                Response.Flush();
                Response.End();
            }
            else
            {
                if (docClsDT.Rows.Count == 1 || (tmpDocCls.Count() == 1 && docClsDT.Rows.Count == 2))
                {
                    //不显示左边的树
                    //ViewData["docClsCd"] = tmpDocCls[0]["FDocClsCd"].ToString();
                    docClsCd = tmpDocCls[0]["FDocClsCd"].ToString();
                    Model.DocCls docClsModel = docClsBLL.GetModel(entityNo, docClsCd);
                    if (docClsModel != null)
                    {
                        if (docClsModel.FDocClsProp == "2")
                        {
                            //单信息
                            decimal docId = documentBLL.GetDocIdDocClsCd(entityNo, docClsCd);
                            if (docId > 0)
                            {
                                actionResult = Lzzf_Detail(docId, docClsModel.FDocClsCd);
                            }
                        }
                    }

                }
                else
                {
                    if (tmpDocCls.Count() == 1)
                    {
                        //去除0层的节点
                        docClsDT.Rows.Remove(tmpDocCls[0]);
                        tmpDocCls = docClsDT.Select("ClsLevel=1").ToList();
                    }
                    else
                    {
                        tmpDocCls = docClsDT.Select("ClsLevel<0 ").ToList();
                        if (tmpDocCls.Count() == 0)
                        {
                            tmpDocCls = docClsDT.Select("ClsLevel=0 ").ToList();
                        }
                        else
                        {
                            tmpDocCls = docClsDT.Select("ClsLevel<0 OR FPreDocClsCd IS NULL OR FPreDocClsCd='001' ", "FSeq,FDocClsCd").ToList();

                        }


                    }
                    //循环绑定
                    if (tmpDocCls.Count() > 0)
                    {
                        docClsHtml += "<ul>";
                        if (indexClsCd == "")
                        {
                            indexClsCd = tmpDocCls[0]["FDocClsCd"].ToString();
                        }
                        foreach (DataRow dr in tmpDocCls)
                        {
                            docClsHtml += "<li><h2><a href='/Column/Lzzc_DocmentIndex?indexClsCd=" + dr["FDocClsCd"].ToString() + "&clsCd=" + dr["FPreDocClsCd"].ToString();
                            docClsHtml += "' >" + dr["FDocClsName"].ToString() + "</a></h2></li>";
                            if (indexClsCd == dr["FDocClsCd"].ToString())
                            {
                                SetDocClsHtml(ref docClsHtml, docClsDT, dr["FDocClsCd"].ToString());
                            }
                        }

                        docClsHtml += "</ul>";
                    }
                }
                if (actionResult == null)
                {
                    ViewData["docClsHtml"] = docClsHtml;

                    actionResult = View();
                }
            }

            return actionResult;
        }
        /// <summary>
        /// 详细页面
        /// </summary>
        /// <param name="docId">编号</param>
        /// <returns></returns>
        public ActionResult Lzzf_Detail(decimal docId, string docClsCd) 
        {
            ActionResult actionResult = null;
            ViewData["logUrl"] = "";
            ViewData["docClsCd"] = docClsCd;

            IndexController indexCl = new IndexController();
            string viewDocClsCd = "8006";
            actionResult = indexCl.DocView(docId, "Lzzf_Detail", viewDocClsCd);

            return actionResult;
        }
        /// <summary>
        ///递归获取目录树(目前只读取一级子目录)
        /// </summary>
        /// <param name="docClsHtml"></param>
        /// <param name="docSubClsList"></param>
        /// <param name="preDocClsNo"></param>
        /// <param name="className"></param>
        private void SetDocClsHtml(ref string docClsHtml, DataTable deptDocClsDT, string preDocClsNo)
        {
            var tmpDocCls = deptDocClsDT.Select("FPreDocClsCd='" + preDocClsNo + "'").ToList();
            if (tmpDocCls.Count() > 0)
            {
                docClsHtml += "<ul class='sup'>";
                foreach (DataRow dr in tmpDocCls)
                {
                        docClsHtml += "<li><a href='/Column/LzzcList?clsCd=" + dr["FDocClsCd"].ToString()
                                           + "' target='contentFrm' >" + dr["FDocClsName"].ToString() + "</a></li>";
                }
                docClsHtml += "</ul>";
            }
        }

        /// <summary>
        /// 列表页面
        /// </summary>
        /// <param name="clsCd">栏目编号</param>
        /// <param name="id">页码</param>
        /// <returns>视图</returns>
        public ActionResult LzzcList(string clsCd, int id = 1) 
        {
            //ViewData["docClsCd"] = clsCd;
            string entityNo = GlobalConstant.ENTITYNO;
            int pageSize = 20;
            int total = 0;
            List<Models.DocumentGridModel> docGridList = GetDocList(pageSize, out total, clsCd, id);
            PagedList<Models.DocumentGridModel> documentList = new PagedList<Models.DocumentGridModel>(docGridList, id, pageSize, total);
            ViewData["logUrl"] = "";

            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            if (docClsModel != null)
            {
                ViewData["docClsName"] = docClsModel.FDocClsName;
                ViewData["logUrl"] = GetTemplTopPicPath(docClsModel);
                ViewData["focusCd"] = docClsModel.FDocClsCd;
                ViewData["docClsCd"] = docClsModel.FPreDocClsCd;
            }
            return View(documentList);
        }
        /// <summary>
        /// 图片和视频的列表
        /// </summary>
        /// <param name="clsCd">类别编号</param>
        /// <param name="id">页码</param>
        /// <param name="isImage">是否图片 Y 图片 N 视频</param>
        /// <returns></returns>
        public ActionResult LzzcList_ImageOrVideo(string clsCd, int id = 1, string isImage = "Y") 
        {
            BLL.SysPhrase sysyPhraseBLL = new BLL.SysPhrase();
            ViewData["docClsCd"] = clsCd;
            string entityNo = GlobalConstant.ENTITYNO;
            int pageIndex = id;
            int pageSize = 20;
            int total = 0;
            DataSet ds = commonBLL.GetListByPage("t_SysPhrase", "*", pageSize, pageIndex, "", "FPhraseNo", 0, out total);
            List<Model.SysPhrase> docGridList = sysyPhraseBLL.DataTableToList(ds.Tables[0]);
            PagedList<Model.SysPhrase> documentList = new PagedList<Model.SysPhrase>(docGridList, id, pageSize, total);
            ViewData["logUrl"] = "";

            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            if (docClsModel != null)
            {
                ViewData["docClsName"] = docClsModel.FDocClsName;
                ViewData["logUrl"] = GetTemplTopPicPath(docClsModel);
                ViewData["focusCd"] = docClsModel.FDocClsCd;
            }
            return View(documentList);
        }
        /// <summary>
        /// 清风寄语列表
        /// </summary>
        /// <param name="clsCd">类别编号</param>
        /// <param name="id">页码</param>
        /// <returns></returns>
        public ActionResult LzzcList_QFJY(string clsCd, int id = 1) 
        {
            BLL.SysPhrase sysyPhraseBLL = new BLL.SysPhrase();
            ViewData["docClsCd"] = clsCd;
            string entityNo = GlobalConstant.ENTITYNO;
            int pageIndex = id;
            int pageSize = 4;
            int total = 0;
            DataSet ds = commonBLL.GetListByPage("t_SysPhrase", "*", pageSize, pageIndex, "", "FPhraseNo", 0, out total);
            List<Model.SysPhrase> docGridList = sysyPhraseBLL.DataTableToList(ds.Tables[0]);
            PagedList<Model.SysPhrase> documentList = new PagedList<Model.SysPhrase>(docGridList, id, pageSize, total);
            ViewData["logUrl"] = "";

            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            if (docClsModel != null)
            {
                ViewData["docClsName"] = docClsModel.FDocClsName;
                ViewData["logUrl"] = GetTemplTopPicPath(docClsModel);
                ViewData["focusCd"] = docClsModel.FDocClsCd;
            }
            return View(documentList);
        }


        /// <summary>
        /// 廉政之窗头
        /// </summary>
        /// <returns></returns>
        /// 
        [OutputCache(Duration = 1, VaryByParam = "none")]
        public ActionResult LZZCTop(string clsCd = "") 
        {
            ActionResult actionResult = null;

            ViewData["docClsCd"] = clsCd;
            Model.DocCls docClsModel = docClsBLL.GetModel(GlobalConstant.ENTITYNO, clsCd);
            if (docClsModel != null)
            {
                string entityNo = GlobalConstant.ENTITYNO;
                Dictionary<string, List<Models.DocumentGridModel>> dicDocumentList = new Dictionary<string, List<Models.DocumentGridModel>>();
                List<Model.DocCls> subDocClsList = docClsBLL.GetSubDocClsOneList(clsCd, GlobalConstant.ENTITYNO);
                int total = 0;
                dicDocumentList.Add("800601", GetDocList(6, out total, "800601", 1));//法规制度
                total = 0;
                dicDocumentList.Add("800602", GetDocList(6, out total, "800602", 1));//惩防体系
                total = 0;
                dicDocumentList.Add("800603", GetDocList(4, out total, "800603", 1));//史海沉钩
                total = 0;
                dicDocumentList.Add("800604", GetDocList(4, out total, "800604", 1));//廉政学院
                total = 0;
                dicDocumentList.Add("80060402", GetDocList(6, out total, "80060402", 1));//学术体会
                total = 0;
                dicDocumentList.Add("800605", GetDocList(4, out total, "800605", 1));//清风寄语
                total = 0;
                dicDocumentList.Add("800606", GetDocList(4, out total, "800606", 1));//活动掠影
                total = 0;
                dicDocumentList.Add("800607", GetDocList(9, out total, "800607", 1));//工作动态              
                total = 0;
                dicDocumentList.Add("800608", GetDocList(6, out total, "800608", 1));//反腐在线            
                total = 0;
                dicDocumentList.Add("800609", GetDocList(4, out total, "800609", 1));//作风效能

                ViewData["subDocClsList"] = subDocClsList;

                actionResult = View("LZZCTop", dicDocumentList);
            }
            return actionResult;
        }

        /// <summary>
        /// 廉政之窗底部
        /// </summary>
        /// <returns></returns>
        /// 
        [OutputCache(Duration = 1, VaryByParam = "none")]
        public ActionResult LZZCBottom()
        {
            string entityNo = GlobalConstant.ENTITYNO;
            //获取权属
            BLL.Entity entityBLL = new BLL.Entity();
            ViewData["CopyRight"] = entityBLL.GetCopyRight(entityNo).Replace("<br />", "&nbsp;&nbsp;&nbsp;&nbsp;").Replace("\r\n", "");
            return View();
        }
        #endregion


        /// <summary>
        /// 文档局长批示
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string DocLeadInstruct(string docid, string content)
        {
            docid = Fetch.estimateString(docid, CheckGetEnum.Safety);
            content = Fetch.estimateString(content, CheckGetEnum.Safety);
            string val = string.Empty;
            if (docid == string.Empty || content == string.Empty)
            {
                return "empty";
            }
            else
            {

                BLL.LeadInstruct LeadInstructBll = new BLL.LeadInstruct();
                Model.LeadInstruct LeadInstructModel = new Model.LeadInstruct();

                LeadInstructModel.FDocId = decimal.Parse(docid);
                LeadInstructModel.FEmplNo = OperateSession.get(GlobalConstant.PARAM_FEMPLNO);
                if (LeadInstructModel.FEmplNo == null)
                {
                    LeadInstructModel.FEmplNo = "";
                }
                LeadInstructModel.FDeptNo = OperateSession.get(GlobalConstant.PARAM_DEPTNO);
                LeadInstructModel.FEntityNo = OperateSession.get(GlobalConstant.ENTITYNO);
                LeadInstructModel.FExamineDate = DateTime.Now;
                LeadInstructModel.FExamineIP = Request.UserHostAddress;
                LeadInstructModel.FExamineContent = content;
                bool boolvalue = false;
                bool boo = LeadInstructBll.Exists(decimal.Parse(docid), OperateSession.get(GlobalConstant.PARAM_DEPTNO), OperateSession.get(GlobalConstant.ENTITYNO), OperateSession.get(GlobalConstant.PARAM_FEMPLNO));
                if (boo == true)
                {
                    boolvalue = LeadInstructBll.Update(LeadInstructModel);
                }
                else
                {
                    boolvalue = LeadInstructBll.Add(LeadInstructModel);
                    BLL.Document documentBll = new BLL.Document();
                    documentBll.UpdateFisInstruct(docid, OperateSession.get(GlobalConstant.ENTITYNO), "Y");
                }
                if (boolvalue == true)
                {
                    return "yes";
                }
                else
                {
                    return "no";
                }
            }
        }
        /// <summary>
        /// 获取批示内容
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string GetInstruct(string docid)
        {
            docid = Fetch.estimateString(docid, CheckGetEnum.Safety);
            string val = string.Empty;
            if (docid == string.Empty)
            {
                return "empty";
            }
            else
            {

                BLL.LeadInstruct LeadInstructBll = new BLL.LeadInstruct();
                Model.LeadInstruct LeadInstructModel = new Model.LeadInstruct();
                LeadInstructModel = LeadInstructBll.GetModel(decimal.Parse(docid), OperateSession.get(GlobalConstant.PARAM_DEPTNO), OperateSession.get(GlobalConstant.ENTITYNO), OperateSession.get(GlobalConstant.PARAM_FEMPLNO));
                string strCon = "empty";
                if (LeadInstructModel != null)
                {
                    strCon = LeadInstructModel.FExamineContent;
                }

                return strCon;
            }
        }
        /// <summary>
        /// 删除领导批示
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string DelInstruct(string docid)
        {
            docid = Fetch.estimateString(docid, CheckGetEnum.Safety);
            string val = string.Empty;
            if (docid == string.Empty)
            {
                return "empty";
            }
            else
            {

                BLL.LeadInstruct LeadInstructBll = new BLL.LeadInstruct();
                bool boo = LeadInstructBll.Delete(decimal.Parse(docid), OperateSession.get(GlobalConstant.PARAM_DEPTNO), OperateSession.get(GlobalConstant.ENTITYNO), OperateSession.get(GlobalConstant.PARAM_FEMPLNO));
                if (boo == true)
                {
                    BLL.Document documentBll = new BLL.Document();
                    if (!LeadInstructBll.Exists(decimal.Parse(docid), OperateSession.get(GlobalConstant.ENTITYNO)))
                    {
                        documentBll.UpdateFisInstruct(docid, OperateSession.get(GlobalConstant.ENTITYNO), "N");
                    }
                    return "删除成功";
                }
                else
                {
                    return "删除失败";
                }
            }
        }


    }
}
